/*
 * Copyright (c) 2011
 * UNPUBLISHED PROPRIETARY SOURCE CODE.
 */

package com.webservice.domain.dao;

import com.webservice.domain.User;

/**
 * Genereal DAO for {@link User} domain.
 *
 * @author vkolodrevskiy
 */
public interface UserDao {
    /**
     * Creates <code>User</code>.
     *
     * @param user user to save.
     */
    void insert(User user);

    /**
     * Updates <code>User</code>.
     *
     * @param user user to update.
     */
    void update(User user);

    /**
     * Finds user by email.
     *
     * @param email user email.
     * @return <code>User<code>
     */
    User findByEmail(String email);

    /**
     * Finds user by nickname.
     *
     * @param nickname user nickname.
     * @return <code>User<code>
     */
    User findByNickname(String nickname);

    /**
     * Retrieves the {@link User user} with the specified unique identifier.
     *
     * @param id the unique identifier of the <code>User</code> to be returned.
     * @return the <code>User</code> with the specified unique identifer or
     *         <code>null</code> if there is no such item.
     */
    User findById(long id);

    /**
     * Retrieves the {@link User user} with the specified unique token.
     *
     * @param token the unique identifier of the <code>User</code> to be returned.
     * @return the <code>User</code> with the specified unique identifer or
     *         <code>null</code> if there is no such item.
     */
    User findByToken(String token);

    /**
     * Removes (aka sets active=false) user by token.
     * @param id unique id of user to remove.
     */
    void removeById(long id);
}
